home *** CD-ROM | disk | FTP | other *** search
/ Download Now 8 / Download Now V8.iso / Program / InternetTools / ApacheWebServer1.3.6 / apache_1_3_6_win32.exe / _SETUP.1 / Configure < prev    next >
Encoding:
Text File  |  1999-03-21  |  57.7 KB  |  2,032 lines

  1. #!/bin/sh
  2. ## ====================================================================
  3. ## Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  4. ##
  5. ## Redistribution and use in source and binary forms, with or without
  6. ## modification, are permitted provided that the following conditions
  7. ## are met:
  8. ##
  9. ## 1. Redistributions of source code must retain the above copyright
  10. ##    notice, this list of conditions and the following disclaimer. 
  11. ##
  12. ## 2. Redistributions in binary form must reproduce the above copyright
  13. ##    notice, this list of conditions and the following disclaimer in
  14. ##    the documentation and/or other materials provided with the
  15. ##    distribution.
  16. ##
  17. ## 3. All advertising materials mentioning features or use of this
  18. ##    software must display the following acknowledgment:
  19. ##    "This product includes software developed by the Apache Group
  20. ##    for use in the Apache HTTP server project (http://www.apache.org/)."
  21. ##
  22. ## 4. The names "Apache Server" and "Apache Group" must not be used to
  23. ##    endorse or promote products derived from this software without
  24. ##    prior written permission. For written permission, please contact
  25. ##    apache@apache.org.
  26. ##
  27. ## 5. Products derived from this software may not be called "Apache"
  28. ##    nor may "Apache" appear in their names without prior written
  29. ##    permission of the Apache Group.
  30. ##
  31. ## 6. Redistributions of any form whatsoever must retain the following
  32. ##    acknowledgment:
  33. ##    "This product includes software developed by the Apache Group
  34. ##    for use in the Apache HTTP server project (http://www.apache.org/)."
  35. ##
  36. ## THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  37. ## EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  39. ## PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  40. ## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  42. ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  43. ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44. ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  45. ## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  46. ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  47. ## OF THE POSSIBILITY OF SUCH DAMAGE.
  48. ## ====================================================================
  49. ##
  50. ## This software consists of voluntary contributions made by many
  51. ## individuals on behalf of the Apache Group and was originally based
  52. ## on public domain software written at the National Center for
  53. ## Supercomputing Applications, University of Illinois, Urbana-Champaign.
  54. ## For more information on the Apache Group and the Apache HTTP server
  55. ## project, please see <http://www.apache.org/>.
  56.  
  57. # Uses 6 supplemental scripts located in ./helpers:
  58. #    CutRule: Determines the value for a specified Rule
  59. #    GuessOS: Uses uname to determine OS/platform
  60. #    PrintPath: generic "type" or "whence" replacement
  61. #    TestCompile: Can check for libs and if $(CC) is ANSI
  62. #     (i.e., a simple "sanity check")
  63. #    mfhead:
  64. #    fp2rp:
  65. #    slo.sh:
  66.  
  67. exitcode=0
  68. trap 'rm -f $tmpfile $tmpfile2 $tmpfile3 $tmpconfig $awkfile; exit $exitcode' 0 1 2 3 15
  69.  
  70. ####################################################################
  71. ## Set up some defaults
  72. ##
  73. file=Configuration
  74. tmpfile=htconf.$$
  75. tmpfile2=$tmpfile.2
  76. tmpfile3=$tmpfile.3
  77. awkfile=$tmpfile.4
  78. tmpconfig=$tmpfile.5
  79. SUBDIRS="ap main modules"
  80.  
  81. ####################################################################
  82. ## Now handle any arguments, which, for now, is -file
  83. ## to select an alternate Configuration file
  84. ##
  85. while [ "x$1" != "x" ]; do
  86.   if [ "x$1" = "x-file" ] ; then
  87.     shift 1; file=$1; shift 1
  88.     if [ ! -r $file ]; then
  89.       echo "$file does not exist or is not readable."
  90.       exitcode=1
  91.       exit 1
  92.     fi
  93.   else
  94.     echo "ERROR: Bad command line option '$1'"
  95.     echo "  Please read the file INSTALL."
  96.     exit 1
  97.   fi
  98. done
  99. if [ ! -r $file ]; then
  100.   echo "Can't see or read \"$file\""
  101.   echo "Please copy Configuration.tmpl to $file, edit it for your platform,"
  102.   echo "and re-run $0 again."
  103.   exitcode=1
  104.   exit 1
  105. fi
  106.  
  107. ####################################################################
  108. ## Now see if Configuration.tmpl is more recent than $file. If
  109. ## so, then we complain and bail out
  110. ##
  111. if ls -lt Configuration.tmpl $file | head -1 | \
  112.   grep 'Configuration.tmpl' > /dev/null
  113. then
  114.   echo "Configuration.tmpl is more recent than $file;"
  115.   echo "Make sure that $file is valid and, if it is, simply"
  116.   echo "'touch $file' and re-run $0 again."
  117.   exitcode=1
  118.   exit 1
  119. fi
  120.  
  121. echo "Using config file: $file"
  122.  
  123. ####################################################################
  124. ## From the Configuration file, create a "cleaned-up" version
  125. ## that's easy to scan
  126. ##
  127.  
  128. # Strip comments and blank lines, remove whitespace around
  129. # "=" assignments, change Rules to comments and then remove whitespace
  130. # before Module declarations
  131. sed 's/#.*//' $file | \
  132.  sed '/^[     ]*$/d' | \
  133.  sed 's/[     ]*$//' | \
  134.  sed 's/[     ]*=[     ]*/=/' | \
  135.  sed '/^Rule[     ]*/d' | \
  136.  sed 's/^[     ]*AddModule/AddModule/' | \
  137.  sed 's/^[     ]*%AddModule/%AddModule/' | \
  138.  sed 's/^[     ]*SharedModule/SharedModule/' | \
  139.  sed 's/^[     ]*Module/Module/' | \
  140.  sed 's/^[     ]*%Module/%Module/' > $tmpfile
  141.  
  142. # Determine if shared objects are used
  143. using_shlib=`grep  '^SharedModule' $tmpfile >/dev/null && echo 1`
  144.  
  145. # But perhaps later via apxs when just mod_so is compiled in!
  146. if [ "x$using_shlib" = "x" ]; then
  147.     using_shlib=`grep  '^AddModule modules/standard/mod_so.o' $tmpfile >/dev/null && echo 1`
  148. fi
  149.  
  150. # Only "assignment" ("=") statements and Module lines
  151. # should be left at this point. If there is other stuff
  152. # we bail out
  153. if egrep -v '^%?Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$' $tmpfile \
  154.  | egrep -v '^%?AddModule[     ]+[^     ]+$' \
  155.  | egrep -v '^SharedModule[     ]+[^     ]+$' \
  156.  | grep -v = > /dev/null
  157. then
  158.   echo "Syntax error --- The configuration file is used only to"
  159.   echo "define the list of included modules or to set Makefile"
  160.   echo "options or Configure rules, and I don't see that at all:"
  161.   egrep -v '^%?Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$' $tmpfile \
  162.    | egrep -v '^%?AddModule[     ]+[^     ]+$'  \
  163.    | egrep -v '^%?SharedModule[     ]+[^     ]+$'  \
  164.    | grep -v =
  165.   exitcode=1
  166.   exit 1
  167. fi
  168.  
  169. ####################################################################
  170. ## If we find the directory /usr/local/etc/httpd and there is
  171. ## no HTTPD_ROOT flag set in the Configuration file we assume
  172. ## that the user was using the old default root directory
  173. ## and issue a notice about it.
  174. ##
  175. if [ "x$file" != "xConfiguration.apaci" ]
  176. then
  177.   if [ -d /usr/local/etc/httpd/ ]
  178.   then
  179.     if egrep '^EXTRA_CFLAGS.*HTTPD_ROOT' $file >/dev/null
  180.     then
  181.       :
  182.     else
  183.       echo " | Please note that the default httpd root directory has changed"
  184.       echo " | from '/usr/local/etc/httpd/' to '/usr/local/apache/.'"
  185.       echo " | You may add '-DHTTPD_ROOT=\\\"/usr/local/etc/httpd\\\"' to EXTRA_CFLAGS"
  186.       echo " | in your Configuration file (and re-run Configure) or start"
  187.       echo " | httpd with the option '-d /usr/local/etc/httpd' if you still"
  188.       echo " | want to use the old root directory for your server."
  189.     fi
  190.   fi
  191. fi
  192.  
  193. ####################################################################
  194. ## Start creating the Makefile. We add some comments and
  195. ## then fold in the modules that were included in Configuration
  196. ##
  197. echo "Creating Makefile"
  198. ./helpers/mfhead . $file > Makefile
  199.  
  200. ####################################################################
  201. ## Now we create a stub file, called Makefile.config, which
  202. ## just includes those assignments (eg: CC=gcc) in Configuration
  203. ##
  204. awk >Makefile.config <$tmpfile '
  205.     BEGIN {
  206.     print "##"
  207.     print "##  Inherited Makefile options from Configure script"
  208.     print "##  (Begin of automatically generated section)"
  209.     print "##"
  210.     print "SRCDIR=."
  211.     } 
  212.     /\=/ { print } 
  213.     '
  214.  
  215. ####################################################################
  216. ## Extract the rules.
  217. ##
  218. RULE_WANTHSREGEX=`./helpers/CutRule WANTHSREGEX $file`
  219. RULE_STATUS=`./helpers/CutRule STATUS $file`
  220. RULE_SOCKS4=`./helpers/CutRule SOCKS4 $file`
  221. RULE_SOCKS5=`./helpers/CutRule SOCKS5 $file`
  222. RULE_IRIXNIS=`./helpers/CutRule IRIXNIS $file`
  223. RULE_IRIXN32=`./helpers/CutRule IRIXN32 $file`
  224. RULE_PARANOID=`./helpers/CutRule PARANOID $file`
  225. RULE_SHARED_CORE=`./helpers/CutRule SHARED_CORE $file`
  226. RULE_SHARED_CHAIN=`./helpers/CutRule SHARED_CHAIN $file`
  227.  
  228. ####################################################################
  229. ## Rule SHARED_CORE implies required DSO support
  230. ##
  231. if [ "x$RULE_SHARED_CORE" = "xyes" ]; then
  232.     using_shlib=1
  233. fi
  234.  
  235. ####################################################################
  236. ## Preset some "constants";
  237. ## can be overridden on a per-platform basis below.
  238. ##
  239. DBM_LIB="-ldbm"
  240. DB_LIB="-ldb"
  241. SHELL="/bin/sh"
  242. SUBTARGET="target_static"
  243. SHLIB_SUFFIX_NAME=""
  244. SHLIB_SUFFIX_LIST=""
  245. CAT="cat"
  246.  
  247. ####################################################################
  248. ## Now we determine the OS/Platform automagically, thanks to
  249. ## GuessOS, a home-brewed OS-determiner ala config.guess
  250. ##
  251. ## We adjust CFLAGS, LIBS, LDFLAGS and INCLUDES (and other Makefile
  252. ## options) as required. Setting CC and OPTIM here has no effect
  253. ## if they were set in Configure.
  254. ##
  255. ## Also, we set DEF_WANTHSREGEX and to the appropriate
  256. ## value for each platform.
  257. ##
  258. ## As more PLATFORMs are added to Configuration.tmpl, be sure to
  259. ## add the required lines below.
  260. ##
  261. PLAT=`./helpers/GuessOS`
  262. SHELL="/bin/sh"
  263. OSDIR="os/unix"
  264.  
  265. case "$PLAT" in
  266.     *mint)
  267.     OS="MiNT"
  268.     CFLAGS="-DMINT"
  269.     LIBS="$LIBS -lportlib -lsocket"
  270.     DEF_WANTHSREGEX=yes
  271.     ;;
  272.     *MPE/iX*)
  273.     OS='MPE/iX'
  274.     CFLAGS="$CFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE"
  275.     LIBS="$LIBS -lsocket -lsvipc"
  276.     LDFLAGS="$LDFLAGS -Xlinker \"-WL,cap=ia,ba,ph,pm;nmstack=1024000\""
  277.     CAT="/bin/cat" # built-in cat is badly broken for stdin redirection
  278.     ;;
  279.     *-apple-aux3*)
  280.     OS='A/UX 3.1.x'
  281.     CFLAGS="$CFLAGS -DAUX3 -D_POSIX_SOURCE"
  282.     LIBS="$LIBS -lposix -lbsd"
  283.     LDFLAGS="$LDFLAGS -s"
  284.     DEF_WANTHSREGEX=no
  285.     ;;
  286.     i386-ibm-aix*)
  287.     OS='IBM AIX PS/2'
  288.     CFLAGS="$CFLAGS -DAIX=1 -U__STR__ -DUSEBCOPY"
  289.     DEF_WANTHSREGEX=no
  290.     ;;
  291.     *-ibm-aix[1-2].*)
  292.     OS='IBM AIX 1.x/2.x'
  293.     CFLAGS="$CFLAGS -DAIX=1 -DNEED_RLIM_T -U__STR__"
  294.     ;;
  295.     *-ibm-aix3.*)
  296.     OS='IBM AIX 3.x'
  297.     CFLAGS="$CFLAGS -DAIX=30 -DNEED_RLIM_T -U__STR__"
  298.     ;;
  299.     *-ibm-aix4.1)
  300.     OS='IBM AIX 4.1'
  301.     CFLAGS="$CFLAGS -DAIX=41 -DNEED_RLIM_T -U__STR__"
  302.     ;;
  303.     *-ibm-aix4.2)
  304.     OS='IBM AIX 4.2'
  305.     CFLAGS="$CFLAGS -DAIX=42 -U__STR__"
  306.     LDFLAGS="$LDFLAGS -lm"
  307.     ;;
  308.     *-ibm-aix4.3)
  309.     OS='IBM AIX 4.3'
  310.     CFLAGS="$CFLAGS -DAIX=43 -U__STR__"
  311.     LDFLAGS="$LDFLAGS -lm"
  312.     RULE_SHARED_CORE=no
  313.     DEF_SHARED_CORE=no
  314.     using_shlib=0
  315.     ;;
  316.     *-ibm-aix*)
  317.     OS='IBM AIX'
  318.     CFLAGS="$CFLAGS -DAIX=1 -U__STR__"
  319.     LDFLAGS="$LDFLAGS -lm"
  320.     ;;
  321.     *-apollo-*)
  322.     OS='Apollo Domain'
  323.     CFLAGS="$CFLAGS -DAPOLLO"
  324.     ;;
  325.     *-dg-dgux*)
  326.     OS='DG/UX 5.4'
  327.     CFLAGS="$CFLAGS -DDGUX"
  328.     DEF_WANTHSREGEX=yes
  329.     ;;
  330.     *OS/2*)
  331.     OSDIR="os/os2"
  332.     DEF_WANTHSREGEX=yes
  333.     OS='EMX OS/2'
  334.     CFLAGS="$CFLAGS -DOS2 -Zbsd-signals -Zbin-files -DTCPIPV4 -g"
  335.     LDFLAGS="$LDFLAGS -Zexe"
  336.     LIBS="$LIBS -lsocket -lufc -lbsd"
  337.     DBM_LIB="-lgdbm"
  338.     SHELL=sh
  339.     ;;
  340.     *-hi-hiux)
  341.     OS='HI-UX'
  342.     CFLAGS="$CFLAGS -DHIUX"
  343.     ;;
  344.     *-hp-hpux11.*)
  345.     OS='HP-UX 11'
  346.     CFLAGS="$CFLAGS -DHPUX11"
  347.     RANLIB="/bin/true"
  348.     LIBS="$LIBS -lm -lpthread"
  349.     DEF_WANTHSREGEX=yes
  350.     ;;
  351.     *-hp-hpux10.*)
  352.     OS='HP-UX 10'
  353.     CFLAGS="$CFLAGS -DHPUX10"
  354.     RANLIB="/bin/true"
  355.      case "$PLAT" in
  356.        *-hp-hpux10.01)
  357.            # We know this is a problem in 10.01.
  358.            # Not a problem in 10.20.  Otherwise, who knows?
  359.            CFLAGS="$CFLAGS -DSELECT_NEEDS_CAST"
  360.            ;;         
  361.      esac
  362.     DEF_WANTHSREGEX=yes
  363.     ;;
  364.     *-hp-hpux*)
  365.     OS='HP-UX'
  366.     CFLAGS="$CFLAGS -DHPUX"
  367.     RANLIB="/bin/true"
  368.     DEF_WANTHSREGEX=yes
  369.     LIBS="$LIBS -lm"
  370.     ;;
  371.     *-sgi-irix64)
  372.     # Note: We'd like to see patches to compile 64-bit, but for now...
  373.     echo "You are running 64-bit Irix. For now, we will compile 32-bit"
  374.     echo "but if you would care to port to 64-bit, send us the patches."
  375.     DEF_WANTHSREGEX=yes
  376.     DBM_LIB=""
  377.     if [ "x$RULE_IRIXNIS" = "xyes" ]; then
  378.         OS='SGI IRIX-64 w/NIS'
  379.         CFLAGS="$CFLAGS -DIRIX"
  380.         LIBS="$LIBS -lsun"
  381.     else
  382.         OS='SGI IRIX-64'
  383.         CFLAGS="$CFLAGS -DIRIX"
  384.     fi
  385.     ;;
  386.     *-sgi-irix32)
  387.     DEF_WANTHSREGEX=yes
  388.     DBM_LIB=""
  389.     if [ "x$RULE_IRIXN32" = "xyes" ]; then
  390.         if [ "x$RULE_IRIXNIS" = "xyes" ]; then
  391.         OS='SGI IRIX-32 w/NIS'
  392.         else
  393.         OS='SGI IRIX-32'
  394.         fi
  395.     else
  396.         if [ "x$RULE_IRIXNIS" = "xyes" ]; then
  397.         OS='SGI IRIX w/NIS'
  398.         else
  399.         OS='SGI IRIX'
  400.         fi
  401.     fi
  402.     CC='cc'
  403.     CFLAGS="$CFLAGS -DIRIX"
  404.     ;;
  405.     *-sgi-irix)
  406.     DEF_WANTHSREGEX=yes
  407.     DBM_LIB=""
  408.     if [ "x$RULE_IRIXNIS" = "xyes" ]; then
  409.         OS='SGI IRIX w/NIS'
  410.         CFLAGS="$CFLAGS -DIRIX"
  411.         LIBS="$LIBS -lsun"
  412.     else
  413.         OS='SGI IRIX'
  414.         CFLAGS="$CFLAGS -DIRIX"
  415.     fi
  416.     ;;
  417.     *-linux2)
  418.     DEF_WANTHSREGEX=yes
  419.     OS='Linux'
  420.     CFLAGS="$CFLAGS -DLINUX=2"
  421.     LIBS="$LIBS -lm"
  422.     ;;
  423.     *-linux1)
  424.     DEF_WANTHSREGEX=yes
  425.     OS='Linux'
  426.     CFLAGS="$CFLAGS -DLINUX=1"
  427.     ;;
  428.     *-lynx-lynxos)
  429.     OS='LynxOS 2.x'
  430.     CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__ -DLYNXOS"
  431.     LIBS="$LIBS -lbsd -lcrypt"
  432.     DEF_WANTHSREGEX=yes
  433.     ;;
  434.     *486-*-bsdi*)
  435.     OS='BSDI w/486'
  436.     CFLAGS="$CFLAGS -m486"
  437.     DBM_LIB=""
  438.     DB_LIB=""
  439.     ;;
  440.     *-bsdi*)
  441.     OS='BSDI'
  442.     DBM_LIB=""
  443.     DB_LIB=""
  444.     ;;
  445.     *-netbsd*)
  446.     OS='NetBSD'
  447.     CFLAGS="$CFLAGS -DNETBSD"
  448.     LIBS="$LIBS -lcrypt"
  449.     DBM_LIB=""
  450.     DB_LIB=""
  451.     DEF_WANTHSREGEX=no
  452.     ;;
  453.     *-freebsd*)
  454.         PLATOSVERS=`echo $PLAT | sed 's/^.*freebsd//'`
  455.     OS="FreeBSD $PLATOSVERS"
  456.     case "$PLATOSVERS" in
  457.         [23]*)
  458.         DEF_WANTHSREGEX=no
  459.         CFLAGS="$CFLAGS -funsigned-char"
  460.         ;;
  461.     esac
  462.     LIBS="$LIBS -lcrypt"
  463.     DBM_LIB=""
  464.     DB_LIB=""
  465.     ;;
  466.     *-openbsd*)
  467.     OS='OpenBSD'
  468.     DBM_LIB=""
  469.     ;;
  470.     *-next-nextstep*)
  471.     OS='NeXTStep'
  472.     OPTIM='-O'
  473.     CFLAGS="$CFLAGS -DNEXT"
  474.     DEF_WANTHSREGEX=yes
  475.     ;;
  476.     *-next-openstep*)
  477.     OS='OpenStep/Mach'
  478.     CC='cc'
  479.     OPTIM='-O'
  480.     CFLAGS="$CFLAGS -DNEXT"
  481.     CFLAGS_SHLIB='-dynamic -fno-common'
  482.     LD_SHLIB='cc'
  483.     LDFLAGS_SHLIB='-dynamiclib -undefined warning'
  484.     DEF_WANTHSREGEX=yes
  485.     ;;
  486.     *-apple-rhapsody*)
  487.     OS='Mac OS X Server'
  488.     CFLAGS="$CFLAGS -DRHAPSODY"
  489.     DEF_WANTHSREGEX=yes
  490.     ;;
  491.     *-dec-osf*)
  492.     OS='DEC OSF/1'
  493.     CFLAGS="$CFLAGS -DOSF1"
  494.     LIBS="$LIBS -lm"
  495.     ;;
  496.     *-qnx)
  497.     OS='QNX'
  498.     CFLAGS="$CFLAGS -DQNX"
  499.     LIBS="$LIBS -N128k -lsocket -lunix"
  500.     DEF_WANTHSREGEX=yes
  501.     ;;
  502.     *-qnx32)
  503.         CC='cc -F'
  504.     OS='QNX32'
  505.     CFLAGS="$CFLAGS -DQNX -mf -3"
  506.     LIBS="$LIBS -N128k -lsocket -lunix"
  507.     DEF_WANTHSREGEX=yes
  508.     ;;
  509.     *-isc4*)
  510.     OS='ISC 4'
  511.     CC='gcc'
  512.     CFLAGS="$CFLAGS -posix -DISC"
  513.     LDFLAGS="$LDFLAGS -posix"
  514.     LIBS="$LIBS -linet"
  515.     DEF_WANTHSREGEX=yes
  516.     ;;
  517.     *-sco3*)
  518.     OS='SCO 3'
  519.     CFLAGS="$CFLAGS -DSCO -Oacgiltz"
  520.     LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
  521.     DEF_WANTHSREGEX=yes
  522.     ;;
  523.     *-sco5*)
  524.     OS='SCO 5'
  525.     CFLAGS="$CFLAGS -DSCO5"
  526.     LIBS="$LIBS -lsocket -lmalloc -lprot -ltinfo -lx -lm"
  527.     DEF_WANTHSREGEX=no
  528.     ;;
  529.     *-sco_sv*|*-SCO_SV*)
  530.     OS='SCO SV'
  531.     CFLAGS="$CFLAGS -DSCO"
  532.     LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
  533.     DEF_WANTHSREGEX=yes
  534.     ;;
  535.     *-solaris2*)
  536.         PLATOSVERS=`echo $PLAT | sed 's/^.*solaris2.//'`
  537.     OS="Solaris $PLATOSVERS"
  538.     CFLAGS="$CFLAGS -DSOLARIS2=$PLATOSVERS"
  539.     LIBS="$LIBS -lsocket -lnsl"
  540.     DBM_LIB=""
  541.     case "$PLATOSVERS" in
  542.         2[01234]*)
  543.         DEF_WANTHSREGEX=yes
  544.         ;;
  545.         *)
  546.         DEF_WANTHSREGEX=no
  547.         ;;
  548.     esac
  549.     ;;
  550.     *-sunos4*)
  551.     OS='SunOS 4'
  552.     CFLAGS="$CFLAGS -DSUNOS4 -DUSEBCOPY"
  553.     DEF_WANTHSREGEX=yes
  554.     ;;
  555.     *-unixware1)
  556.     DEF_WANTHSREGEX=yes
  557.     OS='UnixWare 1.x'
  558.     CFLAGS="$CFLAGS -DUW=100"
  559.     LIBS="$LIBS -lsocket -lnsl -lcrypt"
  560.     ;;
  561.     *-unixware2)
  562.     DEF_WANTHSREGEX=yes
  563.     OS='UnixWare 2.x'
  564.     CFLAGS="$CFLAGS -DUW=200"
  565.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  566.     ;;
  567.     *-unixware211)
  568.     OS='UnixWare 2.1.1'
  569.     CFLAGS="$CFLAGS -DUW=211"
  570.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  571.     ;;
  572.     *-unixware212)
  573.     OS='UnixWare 2.1.2'
  574.     CFLAGS="$CFLAGS -DUW=212"
  575.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  576.     DBM_LIB=""
  577.     ;;
  578.     *-unixware7)
  579.     OS='UnixWare 7'
  580.     CFLAGS="$CFLAGS -DUW=700"
  581.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  582.     DBM_LIB=""
  583.     ;;
  584.     maxion-*-sysv4*)
  585.         OS='SVR4'
  586.     CFLAGS="$CFLAGS -DSVR4"
  587.     DEF_WANTHSREGEX=yes
  588.     LIBS="$LIBS -lsocket -lnsl -lc -lgen"
  589.     ;;
  590.     *-*-powermax*)
  591.     OS='SVR4'
  592.     CFLAGS="$CFLAGS -DSVR4"
  593.     DEF_WANTHSREGEX=yes
  594.     LIBS="$LIBS -lsocket -lnsl -lgen"
  595.     LD_SHLIB='cc'
  596.     LDFLAGS_SHLIB="-Zlink=so"
  597.     LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
  598.     CFLAGS_SHLIB='-Zpic'
  599.     ;;
  600.     TPF)
  601.        OS='TPF'
  602.        OSDIR='os/tpf'
  603.        CC='c89'
  604.        CFLAGS="$CFLAGS -DTPF -DCHARSET_EBCDIC -D_POSIX_SOURCE"
  605.        DEF_WANTHSREGEX=yes
  606.        LIBS="$LIBS"
  607.        SUBTARGET="target_compile_only"
  608.        ;;
  609.     BS2000*-siemens-sysv4*)
  610.     OS='BS2000'
  611.     OSDIR='os/bs2000'
  612.     CC='c89 -XLLML -XLLMK'
  613.     CFLAGS="$CFLAGS -DCHARSET_EBCDIC -DSVR4 -D_XPG_IV"
  614.     DEF_WANTHSREGEX=yes
  615.     LIBS="$LIBS -lsocket -lnsl -lc"
  616.     DBM_LIB=""
  617.     ;;
  618.     *-siemens-sysv4*)
  619.     OS='SVR4'
  620.     CFLAGS="$CFLAGS -DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT -DNEED_UNION_SEMUN"
  621.     DEF_WANTHSREGEX=yes
  622.     LIBS="$LIBS -lsocket -lnsl -lc"
  623.     DBM_LIB=""
  624.     ;;
  625.     pyramid-pyramid-svr4)
  626.     OS='SVR4'
  627.     CFLAGS="$CFLAGS -DSVR4 -DNO_LONG_DOUBLE"
  628.     DEF_WANTHSREGEX=yes
  629.     LIBS="$LIBS -lsocket -lnsl -lc"
  630.     ;;
  631.     DS/90\ 7000-*-sysv4*)
  632.     OS='UXP/DS'
  633.     CFLAGS="$CFLAGS -DUXPDS"
  634.     LIBS="$LIBS -lsocket -lnsl"
  635.     DEF_WANTHSREGEX=yes
  636.     ;;
  637.     *-tandem-sysv4*)
  638.     OS='SVR4'
  639.     CFLAGS="$CFLAGS -DSVR4"
  640.     LIBS="$LIBS -lsocket -lnsl"
  641.     DEF_WANTHSREGEX=yes
  642.     ;;
  643.     *-ncr-sysv4)
  644.     OS='NCR MP/RAS'
  645.     CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
  646.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  647.     DEF_WANTHSREGEX=yes
  648.     ;;
  649.     *-sysv4*)
  650.     OS='SVR4'
  651.     CFLAGS="$CFLAGS -DSVR4"
  652.     LIBS="$LIBS -lsocket -lnsl -lc"
  653.     ;;
  654.     88k-encore-sysv4)
  655.     OS='Encore UMAX V'
  656.     CFLAGS="$CFLAGS -DSVR4 -DENCORE"
  657.     DEF_WANTHSREGEX=yes
  658.     LIBS="$LIBS -lPW"
  659.     ;;
  660.     *-uts*)
  661.     OS='Amdahl UTS'
  662.     CFLAGS="$CFLAGS -Xa -eft -DUTS21 -DUSEBCOPY"
  663.     LIBS="$LIBS -lsocket -lbsd -la"
  664.     DEF_WANTHSREGEX=yes
  665.     ;;
  666.     *-ultrix)
  667.     OS='ULTRIX'
  668.     CFLAGS="-DULTRIX"
  669.     DEF_WANTHSREGEX=yes
  670.     SHELL="/bin/sh5"
  671.     ;;
  672.     *powerpc-tenon-machten*)
  673.     OS='MachTen PPC'
  674.     LDFLAGS="$LDFLAGS -Xlstack=0x14000 -Xldelcsect"
  675.     ;;
  676.     *-machten*)
  677.     OS='MachTen 68K'
  678.     LDFLAGS="$LDFLAGS -stack 0x14000"
  679.     DEF_WANTHSREGEX=yes
  680.     ;;
  681.     *convex-v11*)
  682.     OS='CONVEXOS11'
  683.     CFLAGS="$CFLAGS -ext -DCONVEXOS11"
  684.     OPTIM="-O1" # scalar optimization only
  685.     CC='cc'
  686.     DEF_WANTHSREGEX=yes
  687.     ;;
  688.     i860-intel-osf1)
  689.     DEF_WANTHSREGEX=yes
  690.     OS='Paragon OSF/1'
  691.     CFLAGS="$CFLAGS -DPARAGON"
  692.     ;;
  693.     *DYNIX*)
  694.     DEF_WANTHSREGEX=yes
  695.     OS='SEQUENT'
  696.     CFLAGS="$CFLAGS -DSEQUENT"
  697.     ;;
  698.     *NEWS-OS*)
  699.     DEF_WANTHSREGEX=yes
  700.     OS='SONY NEWS-OS'
  701.     CFLAGS="$CFLAGS -DNEWSOS"
  702.     ;;
  703.     *-riscix)
  704.     OS='Acorn RISCix'
  705.     CFLAGS="$CFLAGS -DRISCIX"
  706.     OPTIM="-O"
  707.     MAKE="make"
  708.     DEF_WANTHSREGEX=yes
  709.     ;;
  710.     *-BeOS*)
  711.     OS='BeOS';
  712.     CFLAGS="$CFLAGS -DBEOS"
  713.     DEF_WANTHSREGEX=yes
  714.     ;;
  715.     4850-*.*)
  716.     OS='NCR MP/RAS'
  717.     CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
  718.     DEF_WANTHSREGEX=yes
  719.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  720.     ;;
  721.     drs6000*)
  722.     OS='DRS6000'
  723.     CFLAGS="$CFLAGS -DSVR4"
  724.     DEF_WANTHSREGEX=yes
  725.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  726.     ;;
  727.     m88k-*-CX/SX|CYBER)
  728.     OS='Cyberguard CX/SX'
  729.     CFLAGS="$CFLAGS -D_CX_SX -Xa"
  730.     DEF_WANTHSREGEX=yes
  731.     CC='cc'
  732.     RANLIB='true'
  733.     ;;
  734.     *) # default: Catch systems we don't know about
  735.     OS='Unknown and unsupported OS'
  736.         echo Sorry, but we cannot grok \"$PLAT\"
  737.     echo uname -m
  738.     uname -m
  739.     echo uname -r
  740.     uname -r
  741.     echo uname -s
  742.     uname -s
  743.     echo uname -v
  744.     uname -v
  745.     echo uname -X
  746.     uname -X
  747.     echo Ideally, read the file PORTING, do what it says, and send the
  748.     echo resulting patches to The Apache Group by filling out a report
  749.     echo form at http://www.apache.org/bug_report.html. If you don\'t 
  750.     echo wish to do the port yourself, please submit this output rather 
  751.     echo than the patches. Thank you.
  752.     echo
  753.     echo Pressing on with the build process, but all bets are off.
  754.     echo Do not be surprised if it fails. If it works, and even
  755.     echo if it does not, please contact the above address.
  756.     echo
  757.     ;;
  758. esac
  759.  
  760. ####################################################################
  761. ## set this if we haven't
  762. ##
  763. if [ "x${MAKE}" = "x" ]; then
  764.     MAKE='make'; export MAKE
  765. fi
  766.  
  767. ####################################################################
  768. ## Show user what OS we came up with
  769. ##
  770. echo " + configured for $OS platform"
  771. SUBDIRS="$OSDIR $SUBDIRS"
  772.  
  773. ####################################################################
  774. # Continue building the stub file
  775. # Set variables as soon as possible so that TestCompile can use them
  776. ##
  777. echo >>Makefile.config "OSDIR=\$(SRCDIR)/$OSDIR"
  778. echo >>Makefile.config "INCDIR=\$(SRCDIR)/include"
  779. echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR)"
  780. echo >>Makefile.config "SHELL=$SHELL"
  781.  
  782. ####################################################################
  783. ## And adjust/override WANTHSREGEX as needed
  784. ##
  785. if [ "x$RULE_WANTHSREGEX" = "xdefault" ]; then
  786.     if [ "x$DEF_WANTHSREGEX" = "x" ]; then
  787.         RULE_WANTHSREGEX=yes
  788.     else
  789.         RULE_WANTHSREGEX=$DEF_WANTHSREGEX
  790.     fi
  791. fi
  792.  
  793. ####################################################################
  794. ## Now we determine the C-compiler and optimization level
  795. ## to use. Settings of CC and OPTIM in Configuration have
  796. ## the highest precedence; next comes any settings from
  797. ## the above "OS-specific" section. If still unset,
  798. ## then we look for a known compiler somewhere in PATH
  799. ##
  800.  
  801. # First, look for a CC=<whatever> setting in Configuration (recall, we
  802. # copied these to Makefile.config)
  803. #
  804. # If $TCC is null, then no such line exists in Configuration
  805. #
  806. TCC=`egrep '^CC=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  807. if [ "x$TCC" = "x" ]; then
  808.     if [ "x$CC" = "x" ]; then
  809.     # At this point, CC is not set in Configuration or above, so we
  810.     # try to find one
  811.     for compilers in "gcc" "cc" "acc" "c89"
  812.     do
  813.         lookedfor="$lookedfor $compilers"
  814.         if ./helpers/PrintPath -s $compilers; then
  815.         COMPILER="$compilers"
  816.         break
  817.         fi
  818.     done
  819.     if [ "x$COMPILER" = "x" ]; then
  820.         echo "Error: could not find any of these C compilers"
  821.         echo " anywhere in your PATH: $lookedfor"
  822.         echo "Configure terminated"
  823.         exitcode=1
  824.         exit 1
  825.     fi
  826.     CC=$COMPILER
  827.     fi
  828.     echo " + setting C compiler to $CC"
  829. fi
  830.  
  831. ####################################################################
  832. ## Write the value of $CC to Makefile.config... We only do this
  833. ## is not done already (ie: a 'CC=' line was in Configuration).
  834. ## If there was an entry for it, then set $CC for our own internal
  835. ## use.
  836. ##
  837. if [ "x$TCC" = "x" ]; then
  838.     echo "CC=$CC" >> Makefile.config
  839. else
  840.     CC=$TCC
  841. fi
  842.  
  843. ####################################################################
  844. ## Now check how we can _directly_ run the C pre-processor
  845. ##
  846. TCPP=`egrep '^CPP=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  847. if [ "x$TCPP" != "x" ]; then
  848.     CPP=`CC=$CC CPP=$TCPP ./helpers/findcpp.sh`
  849. else
  850.     CPP=`CC=$CC ./helpers/findcpp.sh`
  851. fi
  852. if [ "x$TCPP" = "x" ]; then
  853.     echo "CPP=$CPP" >> Makefile.config
  854. fi 
  855. echo " + setting C pre-processor to $CPP"
  856.  
  857. ####################################################################
  858. ## Now check for existance of non-standard system header files
  859. ## and start generation of the ap_config_auto.h header
  860. ##
  861. AP_CONFIG_AUTO_H="include/ap_config_auto.h"
  862. echo "/*" >$AP_CONFIG_AUTO_H
  863. echo " *  ap_config_auto.h -- Automatically determined configuration stuff" >>$AP_CONFIG_AUTO_H
  864. echo " *  THIS FILE WAS AUTOMATICALLY GENERATED - DO NOT EDIT!" >>$AP_CONFIG_AUTO_H
  865. echo " */" >>$AP_CONFIG_AUTO_H
  866. echo "" >>$AP_CONFIG_AUTO_H
  867. echo "#ifndef AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H
  868. echo "#define AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H
  869.  
  870. echo " + checking for system header files"
  871. CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h sys/resource.h sys/select.h sys/processor.h"
  872. for header in $CHECK_FOR_HEADERS; do
  873.     echo "" >>$AP_CONFIG_AUTO_H
  874.     echo "/* check: #include <$header> */" >>$AP_CONFIG_AUTO_H
  875.     name="`echo $header | sed -e 's:/:_:g' -e 's:\.:_:g' | tr '[a-z]' '[A-Z]'`"
  876.     CPP=$CPP ./helpers/checkheader.sh $header
  877.     if [ $? -eq 0 ]; then
  878.     echo "#ifndef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  879.     echo "#define HAVE_${name} 1" >>$AP_CONFIG_AUTO_H
  880.     echo "#endif" >>$AP_CONFIG_AUTO_H
  881.     else
  882.     echo "#ifdef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  883.     echo "#undef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  884.     echo "#endif" >>$AP_CONFIG_AUTO_H
  885.     fi
  886. done
  887.  
  888. ####################################################################
  889. # Special AIX 4.x support: need to check for sys/processor.h
  890. # to decide whether the Processor Binding can be used or not
  891. case "$PLAT" in
  892.     *-ibm-aix*)
  893.     CPP=$CPP ./helpers/checkheader.sh sys/processor.h
  894.     if [ $? -eq 0 ]; then
  895.         CFLAGS="$CFLAGS -DAIX_BIND_PROCESSOR"
  896.     fi
  897.     ;;
  898. esac
  899.  
  900. ####################################################################
  901. ## Look for OPTIM and save for later
  902. ##
  903. TOPTIM=`egrep '^OPTIM=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  904. TRANLIB=`egrep '^RANLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  905. TTARGET=`egrep '^TARGET=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  906.  
  907. ####################################################################
  908. ## Check for user provided flags for shared object support
  909. ##
  910. TLD_SHLIB=`egrep '^LD_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  911. TLDFLAGS_SHLIB=`egrep '^LDFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  912. TLDFLAGS_SHLIB_EXPORT=`egrep '^LDFLAGS_SHLIB_EXPORT=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  913. TCFLAGS_SHLIB=`egrep '^CFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  914.  
  915. ####################################################################
  916. ## Handle TARGET name
  917. ##
  918. if [ "x$TTARGET" = "x" ]; then
  919.     TARGET=httpd
  920.     echo "TARGET=$TARGET" >> Makefile.config
  921. else
  922.     TARGET=$TTARGET
  923. fi
  924. if [ "x$TARGET" != "xhttpd" ]; then
  925.     echo " + using custom target name: $TARGET"
  926.     CFLAGS="$CFLAGS -DTARGET=\\\"$TARGET\\\""
  927. fi
  928.  
  929. ####################################################################
  930. ## We adjust now CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT as
  931. ## required.  For more platforms just add the required lines below.
  932. ##
  933. if [ "x$using_shlib" = "x1" ] ; then
  934.     LD_SHLIB="ld"
  935.     DEF_SHARED_CORE=no
  936.     DEF_SHARED_CHAIN=no
  937.     SHLIB_SUFFIX_NAME=so
  938.     SHLIB_SUFFIX_DEPTH=all
  939.     SHLIB_EXPORT_FILES=no
  940.     case "$PLAT" in
  941.     *-linux1)
  942.         CFLAGS_SHLIB="-fpic"
  943.         LDFLAGS_SHLIB="-Bshareable"
  944.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  945.         ;;
  946.     *-linux2)
  947.         CFLAGS_SHLIB="-fpic"
  948.         LDFLAGS_SHLIB="-Bshareable"
  949.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  950.         SHLIB_SUFFIX_DEPTH=0
  951.         ;;
  952.     *-freebsd2*)
  953.         CFLAGS_SHLIB="-fpic"
  954.         LDFLAGS_SHLIB="-Bshareable"
  955.         LDFLAGS_SHLIB_EXPORT=""
  956.         SHLIB_SUFFIX_DEPTH=2
  957.         ;;
  958.     *-freebsd3*)
  959.         CFLAGS_SHLIB="-fpic"
  960.         LDFLAGS_SHLIB="-Bshareable"
  961.         OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` 
  962.         if [ "x$OBJFORMAT" = "xelf" ]; then
  963.         LDFLAGS_SHLIB_EXPORT="-Wl,-E"
  964.         SHLIB_SUFFIX_DEPTH=0
  965.         else
  966.         LDFLAGS_SHLIB_EXPORT=""
  967.         SHLIB_SUFFIX_DEPTH=2
  968.         fi  
  969.         ;;
  970.     *-openbsd*)
  971.         CFLAGS_SHLIB="-fPIC"
  972.         LDFLAGS_SHLIB="-Bforcearchive -Bshareable"
  973.         LDFLAGS_SHLIB_EXPORT=""
  974.         SHLIB_SUFFIX_DEPTH=2
  975.         ;;
  976.     alpha-*-netbsd*|mips-*-netbsd*|powerpc-*-netbsd*)
  977.         CFLAGS_SHLIB="-fpic -DPIC"
  978.         LDFLAGS_SHLIB="-shared"
  979.         LDFLAGS_SHLIB_EXPORT=""
  980.         SHLIB_SUFFIX_DEPTH=2
  981.         ;;
  982.     *-netbsd*)
  983.         CFLAGS_SHLIB="-fpic -DPIC"
  984.         LDFLAGS_SHLIB="-Bshareable"
  985.         LDFLAGS_SHLIB_EXPORT=""
  986.         SHLIB_SUFFIX_DEPTH=2
  987.         ;;
  988.     *-bsdi)
  989.         CFLAGS_SHLIB="-fPIC"
  990.         LDFLAGS_SHLIB="-shared"
  991.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  992.         ;;
  993.     *-apple-rhapsody*)
  994.         LD_SHLIB="cc"
  995.         CFLAGS_SHLIB=""
  996.         LDFLAGS_SHLIB='$(EXTRA_LDFLAGS) -bundle -undefined suppress'
  997.         LDFLAGS_SHLIB_EXPORT=""
  998.         SHLIB_SUFFIX_DEPTH=0
  999.         ;;
  1000.     *-solaris2*)
  1001.         case $CC in
  1002.         */gcc|gcc ) CFLAGS_SHLIB="-fPIC" ;;
  1003.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1004.         esac
  1005.         LDFLAGS_SHLIB="-G"
  1006.         LDFLAGS_SHLIB_EXPORT=""
  1007.         SHLIB_SUFFIX_DEPTH=1
  1008.         ;;
  1009.     *-sunos4*)
  1010.         case $CC in
  1011.         */gcc|gcc ) CFLAGS_SHLIB="-fPIC" ;;
  1012.         */acc|acc ) CFLAGS_SHLIB="-pic" ;;
  1013.         esac
  1014.         LDFLAGS_SHLIB="-assert pure-text"
  1015.         LDFLAGS_SHLIB_EXPORT=""
  1016.         ;;
  1017.     *-sgi-irix32)
  1018.         case $CC in
  1019.         */gcc|gcc )
  1020.             CFLAGS_SHLIB="-fpic"
  1021.             N32FLAG=""
  1022.             ;;
  1023.         */cc|cc )
  1024.             CFLAGS_SHLIB="-KPIC"
  1025.             N32FLAG="-n32"
  1026.             ;;
  1027.         esac
  1028.         if [ "x$RULE_IRIXN32" = "xyes" ]; then
  1029.         LDFLAGS_SHLIB="$N32FLAG -shared"
  1030.         else
  1031.         LDFLAGS_SHLIB="-shared"
  1032.         fi
  1033.         LDFLAGS_SHLIB_EXPORT=""
  1034.         ;;
  1035.     *-sgi-irix64)
  1036.         case $CC in
  1037.         */gcc|gcc )
  1038.             CFLAGS_SHLIB="-fpic"
  1039.             N32FLAG=""
  1040.             ;;
  1041.         */cc|cc )
  1042.             CFLAGS_SHLIB="-KPIC"
  1043.             N32FLAG="-n32"
  1044.             ;;
  1045.         esac
  1046.         if [ "x$RULE_IRIXN32" = "xyes" ]; then
  1047.         LDFLAGS_SHLIB="$N32FLAG -shared"
  1048.         else
  1049.         LDFLAGS_SHLIB="-shared"
  1050.         fi
  1051.         LDFLAGS_SHLIB_EXPORT=""
  1052.         ;;
  1053.     *-sgi-irix)
  1054.         case $CC in
  1055.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1056.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1057.         esac
  1058.         LDFLAGS_SHLIB="-shared"
  1059.         LDFLAGS_SHLIB_EXPORT=""
  1060.         ;;
  1061.     *-dec-osf*)
  1062.         case $CC in
  1063.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1064.         */cc|cc   ) CFLAGS_SHLIB="" ;;
  1065.         esac
  1066.         LDFLAGS_SHLIB="-shared -expect_unresolved '*' -s"
  1067.         LDFLAGS_SHLIB_EXPORT=""
  1068.         ;;
  1069.     *-unixware*)
  1070.         case $CC in
  1071.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1072.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1073.         esac
  1074.         LDFLAGS_SHLIB="-Bdynamic -G"
  1075.         LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
  1076.         ;;
  1077.      *-sco5*)
  1078.          case $CC in
  1079.          */gcc*|gcc* ) CFLAGS_SHLIB="-fpic" ;;
  1080.          */cc*|cc*   ) CFLAGS_SHLIB="-KPIC" ;;
  1081.          esac
  1082.          LDFLAGS_SHLIB="-G"
  1083.          LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
  1084.          SHLIB_SUFFIX_DEPTH=1
  1085.          ;;
  1086.     RM*-siemens-sysv4*)
  1087.         # MIPS hosts can take advantage of the LDFLAGS_SHLIB_EXPORT switch
  1088.         case $CC in
  1089.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1090.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1091.         esac
  1092.         LDFLAGS_SHLIB="-G"
  1093.         LDFLAGS_SHLIB_EXPORT="-Wl,-Blargedynsym"
  1094.         ;;
  1095.     *-siemens-sysv4*)
  1096.         # Older SINIX machines must be linked as "shared core"-Apache
  1097.         case $CC in
  1098.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1099.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1100.         esac
  1101.         LDFLAGS_SHLIB="-G"
  1102.         LDFLAGS_SHLIB_EXPORT=""
  1103.         SHLIB_SUFFIX_DEPTH=0
  1104.         DEF_SHARED_CORE=yes
  1105.         ;;
  1106.     *-sysv4*)
  1107.         case $CC in
  1108.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1109.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1110.         esac
  1111.         LDFLAGS_SHLIB="-G"
  1112.         LDFLAGS_SHLIB_EXPORT=""
  1113.         DEF_SHARED_CORE=yes
  1114.         ;;
  1115.     *-hp-hpux9.*)
  1116.         case $CC in
  1117.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1118.         */cc|cc   ) CFLAGS_SHLIB="+z" ;;
  1119.         esac
  1120.         LDFLAGS_SHLIB="-b"
  1121.         LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred"
  1122.         SHLIB_SUFFIX_NAME=sl
  1123.         ;;
  1124.     *-hp-hpux10.*|*-hp-hpux11.*)
  1125.         case $CC in
  1126.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1127.         */cc|cc   ) CFLAGS_SHLIB="+z" ;;
  1128.         esac
  1129.         LDFLAGS_SHLIB="-b"
  1130.         LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred -Wl,+s"
  1131.         SHLIB_SUFFIX_NAME=sl
  1132.         ;;
  1133.     *-ibm-aix*)
  1134.         case $CC in
  1135.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1136.         */cc|cc   ) CFLAGS_SHLIB="" ;;
  1137.         esac
  1138.         case $PLAT in
  1139.         *-ibm-aix4*)
  1140.             LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -bnoentry"
  1141.             ;;
  1142.         *-ibm-aix*)
  1143.             LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -e _nostart"
  1144.             ;;
  1145.         esac
  1146.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bI:\$(SRCDIR)/support/httpd.exp "
  1147.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bE:\`echo \$@|sed -e 's:\.so\$\$:.exp:'\`"
  1148.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -lc"
  1149.         LDFLAGS_SHLIB_EXPORT="-Wl,-bE:\$(SRCDIR)/support/httpd.exp"
  1150.         SHLIB_EXPORT_FILES=yes
  1151.         ;;
  1152.     *-*-powermax*)
  1153.         LD_SHLIB='cc'
  1154.         LDFLAGS_SHLIB="-Zlink=so"
  1155.         LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
  1156.         CFLAGS_SHLIB='-Zpic'
  1157.         ;;
  1158.     *)
  1159.         ##  ok, no known explict support for shared objects
  1160.         ##  on this platform, but we give not up immediately.
  1161.         ##  We take a second chance by guessing the compiler
  1162.         ##  and linker flags from the Perl installation
  1163.         ##  if it exists.
  1164.         PERL=
  1165.         for dir in `echo $PATH | sed -e 's/:/ /g'`
  1166.         do
  1167.         if [ -f "$dir/perl5" ]; then
  1168.             PERL="$dir/perl5"
  1169.             break
  1170.         fi
  1171.         if [ -f "$dir/perl" ]; then
  1172.             PERL="$dir/perl"
  1173.             break
  1174.         fi
  1175.         done
  1176.         if [ "x$PERL" != "x" ]; then
  1177.         #   cool, Perl is installed on this platform...
  1178.         if [ "x`$PERL -V:dlsrc 2>/dev/null | grep dlopen`" != "x" ]; then
  1179.             #   ...and actually uses the dlopen-style interface,
  1180.             #   so we can guess the flags from its knowledge
  1181.             CFLAGS_SHLIB="`$PERL -V:cccdlflags | cut -d\' -f2`"
  1182.             LDFLAGS_SHLIB="`$PERL -V:lddlflags | cut -d\' -f2`"
  1183.             LDFLAGS_SHLIB_EXPORT="`$PERL -V:ccdlflags | cut -d\' -f2`"
  1184.             #   but additionally we have to inform the
  1185.             #   user that we are just guessing the flags
  1186.             echo ""
  1187.             echo "** WARNING: We have no explicit knowledge about shared object"
  1188.             echo "** support for your particular platform. But perhaps you have"
  1189.             echo "** luck: We were able to guess the compiler and linker flags"
  1190.             echo "** for creating shared objects from your Perl installation."
  1191.             echo "** If they actually work, please send the following information"
  1192.             echo "** for inclusion into later releases to new-httpd@apache.org or make"
  1193.             echo "** a suggestion report at http://www.apache.org/bug_report.html:"
  1194.             echo "**     PLATFORM=$PLAT"
  1195.             echo "**     CFLAGS_SHLIB=$CFLAGS_SHLIB"
  1196.             echo "**     LDFLAGS_SHLIB=$LDFLAGS_SHLIB"
  1197.             echo "**     LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT"
  1198.             echo ""
  1199.         fi
  1200.         fi
  1201.         ;;
  1202.     esac
  1203. fi
  1204.  
  1205. ####################################################################
  1206. ## Check if we really have some information to compile
  1207. ## the shared objects if SharedModule was used.
  1208. ##
  1209. if [ "x$using_shlib" = "x1" ] ; then
  1210.     if [ "x$TCFLAGS_SHLIB"  = "x" -a "x$CFLAGS_SHLIB"  = "x"  -a \
  1211.      "x$TLDFLAGS_SHLIB" = "x" -a "x$LDFLAGS_SHLIB" = "x" ]; then
  1212.     echo ""
  1213.     echo "** FAILURE: Sorry, no shared object support available."
  1214.     echo "** Either compile all modules statically (use AddModule instead"
  1215.     echo "** of SharedModule in the Configuration file) or at least provide"
  1216.     echo "** us with the appropriate compiler and linker flags via the"
  1217.     echo "** CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT entries"
  1218.     echo "** in the Configuration file."
  1219.     echo ""
  1220.     exit 1
  1221.     fi
  1222. fi
  1223.  
  1224. ####################################################################
  1225. ## Now we do some OS specific adjustments... for some OSs, we need
  1226. ## to adjust CFLAGS and/or OPTIM depending on which compiler we
  1227. ## are going to use. This is easy, since this can be gleamed from
  1228. ## Makefile.config
  1229. ##
  1230. case "$OS" in
  1231.     'ULTRIX')
  1232.     case "$CC" in
  1233.         */cc|cc ) CFLAGS="$CFLAGS -std" ;;
  1234.     esac
  1235.     ;;
  1236.     'SCO 5')
  1237.     case "$CC" in
  1238.         */cc|cc ) CFLAGS="$CFLAGS -K noinline" ;;
  1239.     esac
  1240.     ;;
  1241.     'HI-UX')
  1242.     case "$CC" in
  1243.         */cc|cc )
  1244.         CFLAGS="$CFLAGS -Aa -D_HIUX_SOURCE"
  1245.         OPTIM=" "
  1246.         TOPTIM=""
  1247.         ;;
  1248.     esac
  1249.     ;;
  1250.     'HP-UX'|'HP-UX 10'|'HP-UX 11')
  1251.     case "$CC" in
  1252.         */cc|cc )
  1253.         CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
  1254.         OPTIM=" "
  1255.         TOPTIM=""
  1256.         ;;
  1257.     esac
  1258.     ;;
  1259.     *IRIX-64*)
  1260.     if [ "x$RULE_IRIXN32" = "xyes" ]; then
  1261.         case "$CC" in
  1262.         */cc|cc )
  1263.             CFLAGS="$CFLAGS -n32"
  1264.             LDFLAGS="$LDFLAGS -n32"
  1265.         ;;
  1266.         esac
  1267.     fi
  1268.     ;;
  1269.     *IRIX-32*)
  1270.     if [ "x$RULE_IRIXN32" = "xyes" ]; then
  1271.         case "$CC" in
  1272.         */cc|cc )
  1273.             CFLAGS="$CFLAGS -n32"
  1274.             LDFLAGS="$LDFLAGS -n32"
  1275.         ;;
  1276.         esac
  1277.     fi
  1278.     ;;
  1279.     IBM?AIX?4.[123])
  1280.     case $CC in
  1281.         */cc|cc ) 
  1282.         CFLAGS="$CFLAGS -qnogenpcomp -qnousepcomp"
  1283.         ;;
  1284.     esac
  1285.     ;;
  1286. esac
  1287.  
  1288. ####################################################################
  1289. ## OK, now we can write OPTIM
  1290. ##
  1291. if [ "x$TOPTIM" = "x" ]; then
  1292.     echo "OPTIM=$OPTIM" >> Makefile.config
  1293. fi
  1294.  
  1295. ####################################################################
  1296. ## OK, now handle RANLIB
  1297. ##
  1298. if [ "x$RANLIB" = "x" ]; then
  1299.     if [ "x$TRANLIB" != "x" ]; then
  1300.     RANLIB=$TRANLIB
  1301.     else
  1302.     if ./helpers/PrintPath -s ranlib; then
  1303.         RANLIB="ranlib"
  1304.     else
  1305.         RANLIB="true"
  1306.     fi
  1307.     fi
  1308. fi
  1309.  
  1310. ####################################################################
  1311. ## Now we do some general checks and some intelligent Configuration
  1312. ## control.
  1313.  
  1314. # Use TestCompile to look for various LIBS
  1315. case "$PLAT" in
  1316.     *-linux*)
  1317.     # newer systems using glibc 2.x need -lcrypt
  1318.     if ./helpers/TestCompile lib crypt; then
  1319.         LIBS="$LIBS -lcrypt"
  1320.     fi
  1321.     ;;
  1322.  
  1323.     *-dg-dgux*)
  1324.     # R4.11MU02 requires -lsocket -lnsl ... no idea if it's earlier or
  1325.     # later than what we already knew about.  PR#732
  1326.     if ./helpers/TestCompile lib socket; then
  1327.         LIBS="$LIBS -lsocket"
  1328.     fi
  1329.     if ./helpers/TestCompile lib nsl; then
  1330.         LIBS="$LIBS -lnsl"
  1331.     fi
  1332.     ;;
  1333. esac
  1334.  
  1335. # SOCKS4 support:
  1336. # We assume that if they are using SOCKS4, then they've
  1337. # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  1338. # otherwise we assume "-L/usr/local/lib -lsocks"
  1339. if [ "x$RULE_SOCKS4" = "xyes" ]; then
  1340.     echo " + enabling SOCKS4 support"
  1341.     CFLAGS="$CFLAGS -DSOCKS -DSOCKS4"
  1342.     CFLAGS="$CFLAGS -Dconnect=Rconnect -Dselect=Rselect"
  1343.     CFLAGS="$CFLAGS -Dgethostbyname=Rgethostbyname"
  1344.     if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks`" = "x" ]; then
  1345.     LIBS="$LIBS -L/usr/local/lib -lsocks"
  1346.     fi
  1347.     case $PLAT in
  1348.     *-solaris2* )
  1349.         LIBS="$LIBS -lresolv"
  1350.         ;;
  1351.     esac
  1352. fi
  1353.  
  1354. # SOCKS5 support:
  1355. # We assume that if they are using SOCKS5, then they've
  1356. # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  1357. # otherwise we assume "-L/usr/local/lib -lsocks5"
  1358. if [ "x$RULE_SOCKS5" = "xyes" ]; then
  1359.     echo " + enabling SOCKS5 support"
  1360.     CFLAGS="$CFLAGS -DSOCKS -DSOCKS5"
  1361.     CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dselect=SOCKSselect"
  1362.     CFLAGS="$CFLAGS -Dgethostbyname=SOCKSgethostbyname -Dclose=SOCKSclose"
  1363.     if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks5`" = "x" ]; then
  1364.     LIBS="$LIBS -L/usr/local/lib -lsocks5"
  1365.     fi
  1366.     case $PLAT in
  1367.     *-solaris2* )
  1368.         LIBS="$LIBS -lresolv"
  1369.         ;;
  1370.     esac
  1371. fi
  1372.  
  1373. ####################################################################
  1374. ## Find out what modules we want and try and configure things for them
  1375. ## Module lines can look like this:
  1376. ##
  1377. ##  Module  name_module    some/path/mod_name[.[oa]]
  1378. ##  AddModule              some/path/mod_name[.[oa]]
  1379. ##
  1380. ## In both cases, the some/path can either be an arbitrary path (including
  1381. ## an absolute path), or a path like "modules/DIR", in which case we _might_
  1382. ## auto-generate a Makefile in modules/DIR (see later).
  1383. ##
  1384. ## The first case is the original style, where we give the module's
  1385. ## name as well as it's binary file location - either a .o or .a.
  1386. ##
  1387. ## The second format is new, and means we do not repeat the module
  1388. ## name, which is already part of the module source or definition.
  1389. ## The way we find the module name (and other optional information about
  1390. ## the module) is like this:
  1391. ##
  1392. ##  1 If extension is not given or is .c, assume .o was given and goto 3
  1393. ##  2 If extension is .module, go to D1
  1394. ##  3 If extension is .o, look for a corresponding .c file and if
  1395. ##      found, go to C1
  1396. ##  4 If no .c file was found, look for a .module file (Apache module
  1397. ##      definition file). If found, go to D1
  1398. ##  5 Assume module name is the "name" part of "mod_name", as in
  1399. ##      name_module.
  1400. ##
  1401. ## If a C file is found:
  1402. ##
  1403. ## C1 Look for module name given by an MODULE: line (e.g. MODULE: name_module)
  1404. ##      If found assume module contains a definition, and go to D1
  1405. ## C2 If not found, look for a module name given on the declaration of the
  1406. ##      module structure (e.g. module name_module).
  1407. ## C3 If neither given, go to 4 above.
  1408. ##
  1409. ## If a definition file is found, or a .c file includes a module definition:
  1410. ##
  1411. ## D1 Get the module name from the MODULE: name= line
  1412. ## D2 Get other module options (libraries etc). To be done later.
  1413. ##
  1414. ##
  1415. ## For now, we will convert the AddModule lines into Module format
  1416. ## lines, so the rest of Configure can do its stuff without too much
  1417. ## additional hackery. It would be nice to reduce the number of times
  1418. ## we have to awk the $tmpfile, though.
  1419.  
  1420. ## MODFILES contains a list of module filenames (could be .c, .o, .so, .a
  1421. ##    or .module files) from AddModule lines only
  1422. ## MODDIRS contains a list of subdirectories under 'modules' which
  1423. ##    contain modules we want to build from both AddModule and Module
  1424. ##    lines
  1425.  
  1426. echo " + adding selected modules"
  1427.  
  1428. MODFILES=`awk <$tmpfile '($1 == "AddModule" || $1 == "SharedModule") { printf "%s ", $2 }'`
  1429. MODDIRS=`awk < $tmpfile '
  1430.     ($1 == "Module" && $3 ~ /^modules\//) {
  1431.         split ($3, pp, "/")
  1432.         if (! SEEN[pp[2]]) {
  1433.         printf "%s ", pp[2]
  1434.         SEEN[pp[2]] = 1
  1435.         }
  1436.         }
  1437.     (($1 == "AddModule" || $1 == "SharedModule") && $2 ~ /^modules\//) { 
  1438.         split ($2, pp, "/")
  1439.         if (! SEEN[pp[2]]) {
  1440.         printf "%s ", pp[2]
  1441.         SEEN[pp[2]] = 1
  1442.         } 
  1443.         }'`
  1444. MODDIRS_NO_SO=`awk < $tmpfile '
  1445.     ($1 == "Module" && $3 ~ /^modules\//) {
  1446.         split ($3, pp, "/")
  1447.         if (! SEEN[pp[2]]) {
  1448.         printf "%s ", pp[2]
  1449.         SEEN[pp[2]] = 1
  1450.         }
  1451.         }
  1452.     (($1 == "AddModule") && $2 ~ /^modules\//) { 
  1453.         split ($2, pp, "/")
  1454.         if (! SEEN[pp[2]]) {
  1455.         printf "%s ", pp[2]
  1456.         SEEN[pp[2]] = 1
  1457.         } 
  1458.         }'`
  1459.  
  1460. # Now autoconfigure each of the modules specified by AddModule.
  1461. # Use tmpfile2 for the module definition file, and tmpfile3 for the
  1462. # shell commands to be executed for this module.
  1463.  
  1464. for modfile in $MODFILES ; do
  1465.     rm -f $tmpfile2 $tmpfile3
  1466.     modname=''
  1467.  
  1468.     ext=`echo $modfile | sed 's/^.*\.//'`
  1469.     modbase=`echo $modfile | sed 's/\.[^.]*$//'`
  1470.     if [ "x$ext" = "x$modfile" ]; then ext=o; modbase=$modfile; modfile=$modbase.o; fi
  1471.     if [ "x$ext" = "x" ] ; then ext=o; modbase=$modfile; fi
  1472.     if [ "x$ext" = "xc" ] ; then ext=o; fi
  1473.  
  1474.     # modbase is the path+filename without extension, ext is the
  1475.     # extension given, or if none, o
  1476.     if [ -r $modbase.module ] ; then
  1477.         $CAT $modbase.module > $tmpfile2
  1478.     else
  1479.         if [ -f $modbase.c ] ; then
  1480.         # Guess module structure name in case there is no
  1481.         # module definition in this file
  1482.         modname=`egrep '^module .*;' $modbase.c | head -1 |\
  1483.             sed 's/^module.*[     ][     ]*//' | \
  1484.             sed 's/[     ]*;[     ]*$//'`
  1485.         # Get any module definition part
  1486.         if grep "MODULE-DEFINITION-" $modbase.c > /dev/null; then
  1487.         $CAT $modbase.c | \
  1488.         sed '1,/MODULE-DEFINITION-START/d;/MODULE-DEFINITION-END/,$d' \
  1489.             > $tmpfile2
  1490.         fi
  1491.         fi
  1492.     fi        
  1493.     if [ -r $tmpfile2 ] ; then
  1494.         # Read a module definition from .module or .c
  1495.         modname=`grep "Name:" $tmpfile2 | sed 's/^.*Name:[     ]*//'`
  1496.         if grep "ConfigStart" $tmpfile2 > /dev/null \
  1497.          && grep "ConfigEnd" $tmpfile2 > /dev/null; then
  1498.             sed '1,/ConfigStart/d;/ConfigEnd/,$d' $tmpfile2 > \
  1499.              $tmpfile3
  1500.             echo "    o $modname uses ConfigStart/End"
  1501.             if [ "x$RULE_PARANOID" = "xyes" ]; then
  1502.             sed 's/^/>> /' $tmpfile3
  1503.             fi
  1504.             . ./$tmpfile3
  1505.         fi
  1506.         rm -f $tmpfile2 $tmpfile3
  1507.         if [ "x$ext" != "xso" ]; then
  1508.             ext=o
  1509.         fi
  1510.     fi
  1511.     if [ "x$modname" = "x" ] ; then
  1512.         modname=`echo $modbase | sed 's/^.*\///' | \
  1513.             sed 's/^mod_//' | sed 's/^lib//' | sed 's/$/_module/'`
  1514.     fi
  1515.     if [ "x$ext" != "xso" ]; then
  1516.         echo "Module $modname $modbase.$ext" >>$tmpfile
  1517.     fi
  1518.     #   optionally generate export file for some linkers 
  1519.     if [ "x$ext" = "xso" -a "x$SHLIB_EXPORT_FILES" = "xyes" ]; then
  1520.         echo "$modname" >$modbase.exp
  1521.     fi
  1522. done
  1523. # $tmpfile now contains Module lines for all the modules we want
  1524.  
  1525. ####################################################################
  1526. ## Now HS's POSIX regex implementation if needed/wanted. We do it
  1527. ## now since AddModule may have changed it
  1528. ##
  1529. if [ "x$RULE_WANTHSREGEX" = "xyes" ]; then
  1530.     REGLIB="regex/libregex.a"
  1531.     SUBDIRS="regex $SUBDIRS"
  1532.     CFLAGS="$CFLAGS -DUSE_HSREGEX"
  1533. fi
  1534.  
  1535. ####################################################################
  1536. ## Now the SHARED_CHAIN stuff
  1537. ##
  1538. LIBS_SHLIB=''
  1539. if [ "x$using_shlib" = "x1" ] ; then
  1540.     if [ "x$RULE_SHARED_CHAIN" = "xdefault" ] ; then
  1541.     RULE_SHARED_CHAIN=$DEF_SHARED_CHAIN
  1542.     fi
  1543.     if [ "x$RULE_SHARED_CHAIN" = "xyes" ]; then
  1544.     echo " + enabling DSO files to be linked against others"
  1545.     #   determine libraries which can be safely linked
  1546.     #   to our DSO files, i.e. PIC libraries and shared libraries
  1547.     extra_ldflags="`grep EXTRA_LDFLAGS= Makefile.config`"
  1548.     extra_libs="`grep EXTRA_LIBS= Makefile.config`"
  1549.     eval "`./helpers/slo.sh $LDFLAGS $LIBS $extra_ldflags $extra_libs`"
  1550.     LIBS_SHLIB="$SLO_DIRS_PIC $SLO_LIBS_PIC $SLO_DIRS_DSO $SLO_LIBS_DSO"
  1551.     fi
  1552. fi
  1553.  
  1554. ####################################################################
  1555. ## Now the SHARED_CORE stuff
  1556. ##
  1557. if [ "x$using_shlib" = "x1" ] ; then
  1558.     if [ "x$RULE_SHARED_CORE" = "xdefault" ] ; then
  1559.     RULE_SHARED_CORE=$DEF_SHARED_CORE
  1560.     fi
  1561.     if [ "x$RULE_SHARED_CORE" = "xyes" ]; then
  1562.     echo " + enabling generation of Apache core as DSO"
  1563.     #    shuffle compiler flags from shlib variant to standard
  1564.     CFLAGS="$CFLAGS $CFLAGS_SHLIB"
  1565.     CFLAGS_SHLIB=""
  1566.     #    indicate that Rule SHARED_CORE is active
  1567.     CFLAGS="$CFLAGS -DSHARED_CORE"
  1568.     #    select the special subtarget for shared core generation
  1569.     SUBTARGET=target_shared
  1570.     #    determine additional suffixes for libhttpd.so
  1571.     V=1 R=3 P=6
  1572.     if [ "x$SHLIB_SUFFIX_DEPTH" = "x0" ]; then
  1573.         SHLIB_SUFFIX_LIST=""
  1574.     fi
  1575.     if [ "x$SHLIB_SUFFIX_DEPTH" = "x1" ]; then
  1576.         SHLIB_SUFFIX_LIST="$V"
  1577.     fi
  1578.     if [ "x$SHLIB_SUFFIX_DEPTH" = "x2" ]; then
  1579.         SHLIB_SUFFIX_LIST="$V.$R"
  1580.     fi
  1581.     if [ "x$SHLIB_SUFFIX_DEPTH" = "x3" ]; then
  1582.         SHLIB_SUFFIX_LIST="$V.$R.$P"
  1583.     fi
  1584.     if [ "x$SHLIB_SUFFIX_DEPTH" = "xall" ]; then
  1585.         SHLIB_SUFFIX_LIST="$V $V.$R $V.$R.$P"
  1586.     fi
  1587.     fi
  1588. fi
  1589.  
  1590. ####################################################################
  1591. ## Set the value of the shared libary flags, if they aren't explicitly
  1592. ## set in the configuration file
  1593. ##
  1594. if [ "x$using_shlib" = "x1" ] ; then
  1595.     if [ "x$TCFLAGS_SHLIB" = "x" ]; then
  1596.     echo "CFLAGS_SHLIB=$CFLAGS_SHLIB -DSHARED_MODULE" >> Makefile.config
  1597.     fi
  1598.     if [ "x$TLD_SHLIB" = "x" ]; then
  1599.     echo "LD_SHLIB=$LD_SHLIB" >> Makefile.config
  1600.     fi
  1601.     if [ "x$TLDFLAGS_SHLIB" = "x" ]; then
  1602.     echo "LDFLAGS_SHLIB=$LDFLAGS_SHLIB" >> Makefile.config
  1603.     fi
  1604.     if [ "x$TLDFLAGS_SHLIB_EXPORT" = "x" ]; then
  1605.     echo "LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT" >> Makefile.config
  1606.     fi
  1607. fi
  1608.  
  1609. ####################################################################
  1610. ## Now create modules.c
  1611. ##
  1612. $CAT > $awkfile <<'EOFM'
  1613.     BEGIN {
  1614.     modules[n++] = "core"
  1615.     pmodules[pn++] = "core"
  1616.     } 
  1617.     /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } 
  1618.     /^%Module/ { pmodules[pn++] = $2 } 
  1619.     END {
  1620.     print "/*"
  1621.     print " * modules.c --- automatically generated by Apache"
  1622.     print " * configuration script.  DO NOT HAND EDIT!!!!!"
  1623.     print " */"
  1624.     print ""
  1625.     print "#include \"httpd.h\""
  1626.     print "#include \"http_config.h\""
  1627.     print ""
  1628.     for (i = 0; i < pn; ++i) {
  1629.         printf ("extern module %s_module;\n", pmodules[i])
  1630.     }
  1631.     print ""
  1632.     print "/*"
  1633.     print " *  Modules which implicitly form the"
  1634.     print " *  list of activated modules on startup,"
  1635.     print " *  i.e. these are the modules which are"
  1636.     print " *  initially linked into the Apache processing"
  1637.     print " *  [extendable under run-time via AddModule]"
  1638.     print " */"
  1639.     print "module *ap_prelinked_modules[] = {"
  1640.     for (i = 0; i < n; ++i) {
  1641.         printf "  &%s_module,\n", modules[i]
  1642.     }
  1643.     print "  NULL"
  1644.     print "};"
  1645.     print ""
  1646.     print "/*"
  1647.     print " *  Modules which initially form the"
  1648.     print " *  list of available modules on startup,"
  1649.     print " *  i.e. these are the modules which are"
  1650.     print " *  initially loaded into the Apache process"
  1651.     print " *  [extendable under run-time via LoadModule]"
  1652.     print " */"
  1653.     print "module *ap_preloaded_modules[] = {"
  1654.     for (i = 0; i < pn; ++i) {
  1655.         printf "  &%s_module,\n", pmodules[i]
  1656.     }
  1657.     print "  NULL"
  1658.     print "};"
  1659.     print ""
  1660.     }
  1661. EOFM
  1662. $CAT $tmpfile | sed 's/_module//' | awk -f $awkfile > modules.c 
  1663.  
  1664. ####################################################################
  1665. ## figure out which module dir require use to autocreate a Makefile.
  1666. ## for these dirs we must not list the object files from the AddModule
  1667. ## lines individually since the auto-generated Makefile will create
  1668. ## a library called libMODDIR.a for it (MODDIR is the module dir
  1669. ## name). We create two variable here:
  1670. ##
  1671. ##   AUTODIRS   Space separated list of module directories, relative to
  1672. ##              src
  1673. ##   AUTOLIBS   Space separated list of auto-generated library files
  1674. ##
  1675. for moddir in $MODDIRS 
  1676. do
  1677.     if [ -f modules/$moddir/Makefile.tmpl ] ; then
  1678.         AUTODIRS="$AUTODIRS modules/$moddir"
  1679.     fi
  1680. done
  1681. for moddir in $MODDIRS_NO_SO
  1682. do
  1683.     if [ -f modules/$moddir/Makefile.tmpl ] ; then
  1684.         AUTOLIBS="$AUTOLIBS modules/$moddir/lib$moddir.a"
  1685.     fi
  1686. done
  1687.  
  1688. ####################################################################
  1689. ## Add the module targets to the Makefile. Do not add individual object
  1690. ## targets for auto-generated directories.
  1691. ##
  1692. $CAT > $awkfile <<EOF1
  1693.     BEGIN {
  1694.     split ("$AUTODIRS", tmp, " ")
  1695. EOF1
  1696. $CAT >> $awkfile <<'EOF2'
  1697.     for ( key in tmp ) {
  1698.         autodirs[tmp[key]] = 1
  1699.     }
  1700.      }
  1701.     /^Module/ { modules[n++] = $3 }
  1702.     /^%Module/ { modules[n++] = $3 }
  1703.     END {
  1704.     print "MODULES= \\"
  1705.     for (i = 0; i < n; ++i) {
  1706.         split (modules[i], pp, "/")
  1707.         dir = pp[1] "/" pp[2] 
  1708.         inthere = 0
  1709.         for ( tdir in autodirs ) {
  1710.         if (tdir == dir) 
  1711.             inthere = 1
  1712.         }
  1713.         if (inthere == 1)
  1714.         continue
  1715.         else
  1716.         printf ("  %s \\\n", modules[i])
  1717.     }
  1718.     }
  1719. EOF2
  1720. awk -f $awkfile >>Makefile <$tmpfile
  1721.  
  1722. ####################################################################
  1723. ## Now add the auto-generated library targets.  Need to use awk so we
  1724. ## don't hang a continuation on the last line.
  1725. ##
  1726. $CAT > $awkfile <<'EOF4'
  1727.     {
  1728.     z = 0
  1729.     split ($0, libs)
  1730.     for ( lib in libs ) {
  1731.         if (z != 0)
  1732.         printf (" \\\n")
  1733.         z++
  1734.         printf ("  %s", libs[lib])
  1735.     }
  1736.     }
  1737.     END {
  1738.     printf ("\n")
  1739.     }
  1740. EOF4
  1741. echo "$AUTOLIBS" | awk -f $awkfile >>Makefile
  1742. echo "" >>Makefile
  1743.  
  1744. ####################################################################
  1745. ## Now add the target for the main Makefile
  1746. ##
  1747. echo "SUBDIRS=$SUBDIRS" >> Makefile
  1748. echo "SUBTARGET=$SUBTARGET" >> Makefile
  1749. echo "SHLIB_SUFFIX_NAME=$SHLIB_SUFFIX_NAME" >> Makefile
  1750. echo "SHLIB_SUFFIX_LIST=$SHLIB_SUFFIX_LIST" >> Makefile
  1751. echo "" >> Makefile
  1752.  
  1753. ####################################################################
  1754. ## Determine GNU Make variant because
  1755. ## it uses ugly looking built-in directory walk messages
  1756. ## while we are already using our own messages
  1757. ##
  1758. if [ "x`${MAKE} -v 2>/dev/null | grep 'GNU Make'`" = "x" ]; then
  1759.     MFLAGS_STATIC=
  1760. else
  1761.     MFLAGS_STATIC=--no-print-directory
  1762. fi
  1763.  
  1764. ####################################################################
  1765. ## Continue building Makefile.config. Fill in all entries except
  1766. ## for $LIBS at this point. This implies that anything below
  1767. ## can only alter $LIBS
  1768. ##
  1769. echo "CFLAGS1=$CFLAGS" >>Makefile.config
  1770. echo "INCLUDES1=$INCLUDES" >>Makefile.config
  1771. echo "LIBS_SHLIB=$LIBS_SHLIB" >>Makefile.config
  1772. echo "LDFLAGS1=$LDFLAGS" >>Makefile.config
  1773. echo "MFLAGS_STATIC=$MFLAGS_STATIC" >>Makefile.config
  1774. echo "REGLIB=$REGLIB" >>Makefile.config
  1775. echo "RANLIB=$RANLIB" >>Makefile.config
  1776.  
  1777. ####################################################################
  1778. ## Some OS-related stuff for the DSO mechanism:
  1779. ## Finding the vendor DSO functions
  1780. ##
  1781. if [ "x$using_shlib" = "x1" ] ; then
  1782.     DL_LIB=""
  1783.     case $PLAT in
  1784.     *-ibm-aix* )
  1785.         DL_LIB="-lld"
  1786.         ;;
  1787.     *-hp-hpux*)
  1788.         if ./helpers/TestCompile func shl_load; then
  1789.         :
  1790.         else
  1791.         if ./helpers/TestCompile lib dld; then
  1792.             DL_LIB="-ldld"
  1793.         fi
  1794.         fi
  1795.         ;;
  1796.     * )
  1797.         if ./helpers/TestCompile func dlopen; then
  1798.         :
  1799.         else
  1800.         if ./helpers/TestCompile lib dl; then
  1801.             DL_LIB="-ldl"
  1802.         fi
  1803.         fi
  1804.         ;;
  1805.     esac
  1806.     if [ "x$DL_LIB" != "x" ]; then
  1807.     LIBS="$LIBS $DL_LIB"
  1808.     echo " + using $DL_LIB for vendor DSO support"
  1809.     fi
  1810. fi
  1811.  
  1812. ####################################################################
  1813. ## Finish building ap_config_auto.h
  1814. ##
  1815. ## We pick out all -D's from CFLAGS and insert them as defines into
  1816. ## ap_config_auto.h so they are available to external modules needing to
  1817. ## include Apache header files.
  1818. ##
  1819. TEXTRA_CFLAGS=`egrep '^EXTRA_CFLAGS=' Makefile.config | tail -1 |\
  1820.            sed -e 's;^EXTRA_CFLAGS=;;' -e 's;\`.*\`;;'`
  1821. tmpstr=`echo $CFLAGS $TEXTRA_CFLAGS |\
  1822.     sed -e 's;[     ]\([+-]\);!\1;g' -e 's/\\\"/\"/g' -e 's/\([^\\]\)"/\1/g'`
  1823. OIFS="$IFS"
  1824. IFS='!'
  1825. for cflag in $tmpstr; do
  1826.     echo "$cflag" >>$tmpconfig
  1827. done
  1828. IFS="$OIFS"
  1829. awk >>$AP_CONFIG_AUTO_H <$tmpconfig '
  1830.     /^-D.*/ {
  1831.     i = index($0, "=")
  1832.     if (i > 0) {
  1833.         define = substr($0, 3, i-3)
  1834.         value  = substr($0, i+1, length($0)-i)
  1835.     }
  1836.     else {
  1837.         define = substr($0, 3, length($0)-2)
  1838.         value  = "1";
  1839.     }
  1840.     printf ("\n/* build flag: %s */\n", $0)
  1841.     printf ("#ifndef %s\n#define %s %s\n#endif\n", define, define, value)
  1842.     }
  1843. '
  1844.  
  1845. # finish header file
  1846. echo "" >>$AP_CONFIG_AUTO_H
  1847. echo "#endif /* AP_CONFIG_AUTO_H */" >>$AP_CONFIG_AUTO_H
  1848.  
  1849. ####################################################################
  1850. ## Finish creating the Makefile.config file
  1851. ##
  1852. echo "LIBS1=$LIBS">> Makefile.config
  1853. echo "##" >> Makefile.config
  1854. echo "##  (End of automatically generated section)">> Makefile.config
  1855. echo "##" >> Makefile.config
  1856. echo "" >> Makefile.config
  1857.  
  1858. ####################################################################
  1859. ## Use TestCompile to see if $(CC) is ANSI and as a "final" sanity
  1860. ## check
  1861. ##
  1862.  
  1863. if [ "x$OS" = "xTPF" ] ; then
  1864.     :
  1865. else
  1866.    echo " + doing sanity check on compiler and options"
  1867.    if ./helpers/TestCompile sanity; then
  1868.       :
  1869.    else
  1870.    echo "** A test compilation with your Makefile configuration"
  1871.    echo "** failed. This is most likely because your C compiler"
  1872.    echo "** is not ANSI. Apache requires an ANSI C Compiler, such"
  1873.    echo "** as gcc. The above error message from your compiler"
  1874.    echo "** will also provide a clue."
  1875.    echo " Aborting!"
  1876.    exitcode=1
  1877.    exit 1
  1878.    fi
  1879. fi
  1880.  
  1881. ####################################################################
  1882. ## Now (finish) creating the makefiles
  1883. ##
  1884.  
  1885. # ./Makefile
  1886. $CAT Makefile.config >> Makefile
  1887. sed -e "s#@@Configuration@@#$file#" "Makefile.tmpl" >>Makefile
  1888.  
  1889. # xxx/Makefile
  1890. MAKEDIRS="support main ap regex $OSDIR"
  1891. for dir in $MAKEDIRS ; do
  1892.     echo Creating Makefile in $dir
  1893.     ./helpers/mfhead $dir $file > $dir/Makefile
  1894.     $CAT Makefile.config $dir/Makefile.tmpl |\
  1895.     sed -e "s:^SRCDIR=.*:SRCDIR=`./helpers/fp2rp $dir`:" >> $dir/Makefile
  1896. done
  1897.  
  1898. ####################################################################
  1899. ## Now create the modules/Makefile
  1900. ##
  1901. ./helpers/mfhead modules $file > modules/Makefile
  1902. $CAT Makefile.config | sed -e 's:^SRCDIR=.*:SRCDIR=..:' >> modules/Makefile
  1903.  
  1904. $CAT << EOF >> modules/Makefile
  1905. MODULES=$MODDIRS
  1906. CFLAGS=\$(OPTIM) \$(CFLAGS1) \$(EXTRA_CFLAGS)
  1907.  
  1908. default: all
  1909.  
  1910. all clean distclean depend :: 
  1911.     @for i in \$(MODULES) ""; do \\
  1912.       if [ "x\$\$i" != "x" ]; then \\
  1913.         echo "===> \$(SDP)modules/\$\$i"; \\
  1914.         (cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)' CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1; \\
  1915.         echo "<=== \$(SDP)modules/\$\$i"; \\
  1916.       fi; \\
  1917.     done
  1918.  
  1919. EOF
  1920.  
  1921. ####################################################################
  1922. ## Now create modules/xxx/Makefile
  1923. ##
  1924. for moddir in $AUTODIRS ; do
  1925.     echo "Creating Makefile in $moddir"
  1926.  
  1927.     ./helpers/mfhead $moddir $file > $moddir/Makefile
  1928.     $CAT Makefile.config |\
  1929.     sed -e "s:^SRCDIR=.*:SRCDIR=`./helpers/fp2rp $moddir`:" >> $moddir/Makefile
  1930.     $CAT << 'EOF' >> $moddir/Makefile
  1931. ##
  1932. ##  Default Makefile options from Configure script
  1933. ##  (Begin of automatically generated section)
  1934. ##
  1935. CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
  1936. LIBS=$(EXTRA_LIBS) $(LIBS1)
  1937. INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
  1938. LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
  1939. INCDIR=$(SRCDIR)/include
  1940. EOF
  1941.     if [ -f $moddir/Makefile.libdir ]; then
  1942.         basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
  1943.         awk >> $moddir/Makefile < $tmpfile '
  1944.         ($2 ~ /^modules\/'$basedir'\//) {
  1945.             split($2, pp, "/");
  1946.             split(pp[3], parts, ".");
  1947.             libext=parts[2];
  1948.         }
  1949.         END { 
  1950.             printf "LIBEXT=%s\n", libext;
  1951.         }'
  1952.         # it's responsible for the rest of its Makefile...
  1953.     else
  1954.         basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
  1955.         OBJS=`awk < $tmpfile '
  1956.         ($1 == "Module" && $3 ~ /^modules\/'$basedir'\//) { 
  1957.             split ($3, pp, "/")
  1958.             printf "%s ", pp[3] 
  1959.         } 
  1960.         '`
  1961.         echo "OBJS=$OBJS" >> $moddir/Makefile
  1962.         if [ "x$OBJS" != "x" ]; then
  1963.         echo "LIB=lib$basedir.a" >> $moddir/Makefile
  1964.         else
  1965.         #   essential!
  1966.         echo "LIB=" >> $moddir/Makefile
  1967.         fi
  1968.         awk >> $moddir/Makefile < $tmpfile '
  1969.         ($1 == "SharedModule" && $2 ~ /^modules\/'$basedir'\//) {
  1970.         split($2, pp, "/")
  1971.         shlibs=shlibs " " pp[3]
  1972.         so=pp[3]
  1973.         split(pp[3], parts, ".")
  1974.         base=parts[1]
  1975.         objspic=objspic " " base ".lo"
  1976.         }
  1977.         END { 
  1978.         printf "SHLIBS=%s\n", shlibs;
  1979.         printf "OBJS_PIC=%s\n", objspic;
  1980.         }'
  1981.  
  1982.         $CAT << 'EOF' >> $moddir/Makefile
  1983.  
  1984. all: lib shlib
  1985.  
  1986. lib:    $(LIB) 
  1987.  
  1988. shlib:    $(SHLIBS)
  1989.  
  1990. dummy $(LIB): $(OBJS)
  1991.     rm -f $@
  1992.     ar cr $@ $(OBJS)
  1993.     $(RANLIB) $@
  1994.  
  1995. .SUFFIXES: .o .so
  1996.  
  1997. .c.o:
  1998.     $(CC) -c $(INCLUDES) $(CFLAGS) $<
  1999.  
  2000. .c.so:
  2001.     $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo
  2002.     $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $*.lo $(LIBS_SHLIB)
  2003.  
  2004. clean:
  2005.     rm -f $(LIB) $(OBJS) $(SHLIBS) $(OBJS_PIC)
  2006.  
  2007. distclean: clean
  2008.     rm -f Makefile
  2009.  
  2010. #   NOT FOR END USERS!
  2011. depend:
  2012.     cp Makefile.tmpl Makefile.tmpl.bak \
  2013.         && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
  2014.         && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  2015.         && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
  2016.            -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
  2017.         > Makefile.tmpl \
  2018.         && rm Makefile.new
  2019.  
  2020. EOF
  2021.     fi
  2022.  
  2023.     $CAT << 'EOF' >> $moddir/Makefile
  2024. ##
  2025. ##  (End of automatically generated section)
  2026. ##
  2027. EOF
  2028.     $CAT >> $moddir/Makefile < $moddir/Makefile.tmpl
  2029.  
  2030. done
  2031.  
  2032.